home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / intuition / modifyidcmp.c < prev    next >
C/C++ Source or Header  |  1996-11-08  |  4KB  |  135 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: modifyidcmp.c,v 1.5 1996/11/08 11:28:03 aros Exp $
  4.     $Log: modifyidcmp.c,v $
  5.     Revision 1.5  1996/11/08 11:28:03  aros
  6.     All OS function use now Amiga types
  7.  
  8.     Moved intuition-driver protos to intuition_intern.h
  9.  
  10.     Revision 1.4  1996/10/24 15:51:22  aros
  11.     Use the official AROS macros over the __AROS versions.
  12.  
  13.     Revision 1.3  1996/08/29 13:33:31  digulla
  14.     Moved common code from driver to Intuition
  15.     More docs
  16.  
  17.     Revision 1.2  1996/08/23 17:25:30  digulla
  18.     Added include intuition/intuition.h to user-docs
  19.  
  20.     Revision 1.1  1996/08/13 15:37:27  digulla
  21.     First function for intuition.library
  22.  
  23.  
  24.     Desc:
  25.     Lang: english
  26. */
  27. #include "intuition_intern.h"
  28. #include <clib/exec_protos.h>
  29.  
  30. /*****************************************************************************
  31.  
  32.     NAME */
  33.     #include <intuition/intuition.h>
  34.     #include <clib/intuition_protos.h>
  35.  
  36.     AROS_LH2(BOOL, ModifyIDCMP,
  37.  
  38. /*  SYNOPSIS */
  39.     AROS_LHA(struct Window *, window, A0),
  40.     AROS_LHA(ULONG          , flags, D0),
  41.  
  42. /*  LOCATION */
  43.     struct IntuitionBase *, IntuitionBase, 25, Intuition)
  44.  
  45. /*  FUNCTION
  46.     This routine modifies the state of your window's IDCMP (Intuition
  47.     Direct Communication Message Port).
  48.  
  49.     Depending on the current state in the IDCMPFlags of the window and
  50.     the specified flags these actions are possible:
  51.  
  52.     IDCMP    flags    Action
  53.       0      0    Nothing happens
  54.       0     !=0    The flags are copied in the IDCMPFlags of the window
  55.             and a MessagePort is created and stored in the
  56.             UserPort of the window.
  57.      !=0      0    The IDCMPFlags are cleared and the MessagePort in the
  58.             UserPort is deleted.
  59.      !=0     !=0    The flags are copied to the IDCMPFlags of the
  60.             window.
  61.  
  62.     INPUTS
  63.     window - The window to change the IDCMPFlags in.
  64.     flags - New flags for the IDCMPFlags of the window. See
  65.         intuition/intuition.h for the available flags.
  66.  
  67.     RESULT
  68.     TRUE if the change could be made and FALSE otherwise.
  69.  
  70.     NOTES
  71.     You can set up the Window->UserPort to any port of your own
  72.     before you call ModifyIDCMP().  If IDCMPFlags is non-null but
  73.     your UserPort is already initialized, Intuition will assume that
  74.     it's a valid port with task and signal data preset and Intuition
  75.     won't disturb your set-up at all, Intuition will just allocate
  76.     the Intuition message port half of it.    The converse is true
  77.     as well:  if UserPort is NULL when you call here with
  78.     IDCMPFlags == NULL, Intuition will deallocate only the Intuition
  79.     side of the port.
  80.  
  81.     This allows you to use a port that you already have allocated:
  82.  
  83.     - OpenWindow() with IDCMPFlags equal to NULL (open no ports)
  84.     - set the UserPort variable of your window to any valid port of your
  85.       own choosing
  86.     - call ModifyIDCMP with IDCMPFlags set to what you want
  87.     - then, to clean up later, set UserPort equal to NULL before calling
  88.       CloseWindow() (leave IDCMPFlags alone)  BUT FIRST: you must make
  89.       sure that no messages sent your window are queued at the port,
  90.       since they will be returned to the memory free pool.
  91.  
  92.     For an example of how to close a window with a shared IDCMP,
  93.     see the description for CloseWindow().
  94.  
  95.     EXAMPLE
  96.  
  97.     BUGS
  98.  
  99.     SEE ALSO
  100.     OpenWindow(), CloseWindow()
  101.  
  102.     INTERNALS
  103.  
  104.     HISTORY
  105.     29-10-95    digulla automatically created from
  106.                 intuition_lib.fd and clib/intuition_protos.h
  107.  
  108. *****************************************************************************/
  109. {
  110.     AROS_LIBFUNC_INIT
  111.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  112.  
  113.     if (!window->IDCMPFlags && flags)
  114.     {
  115.     window->UserPort = CreateMsgPort ();
  116.  
  117.     if (!window->UserPort)
  118.         return FALSE;
  119.     }
  120.  
  121.     window->IDCMPFlags = flags;
  122.  
  123.     if (!flags)
  124.     {
  125.     if (window->UserPort)
  126.     {
  127.         DeleteMsgPort (window->UserPort);
  128.         window->UserPort = NULL;
  129.     }
  130.     }
  131.  
  132.     return TRUE;
  133.     AROS_LIBFUNC_EXIT
  134. } /* ModifyIDCMP */
  135.